package com.icinfo.cloud.provider.punish.controller;

import cn.hutool.core.util.ObjectUtil;
import com.icinfo.cloud.provider.common.constant.Constant;
import com.icinfo.cloud.provider.punish.dto.UpdateRegisterTerminalTypeDto;
import com.icinfo.cloud.provider.punish.service.IPrintService;
import com.icinfo.cloud.provider.punish.vo.AppCaseBeforeDocumentDetailVo;
import com.icinfo.cloud.provider.punish.vo.RegisterTerminalTypeVo;
import com.icinfo.cloud.provider.punish.vo.UpdateRegisterTerminalTypeVo;
import com.icinfo.framework.common.web.Result;
import com.icinfo.framework.tools.utils.StringUtils;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;

@RestController
@RequestMapping("/app/print")
public class PrintController {
    @Resource
    private IPrintService printService;

    /**
     * 查询当前设备是否需已有终端类型
     * @author liyafeng
     * @date 2023/3/15
      * @param outsideUid
     * @return {@link Result< AppCaseBeforeDocumentDetailVo>}
     */
    @GetMapping("/getRegisterTerminalType")
    public Result<RegisterTerminalTypeVo>  getRegisterTerminalType(@RequestParam String outsideUid) {
        RegisterTerminalTypeVo vo = printService.getRegisterTerminalType(outsideUid);
        if (ObjectUtil.isNotEmpty(vo)) {
            return Result.success(Constant.STRING_GET_SUCCESS,vo);
        }
        return Result.error("获取终端类型异常");
    }

    /**
     *查询当前PDA是否为黑名单，并进行更新终端设备
     * @author liyafeng
     * @date 2023/3/15
      * @param updateRegisterTerminalTypeDto
     * @return {@link Result< RegisterTerminalTypeVo>}
     */
    @PostMapping("/updateRegisterTerminalType")
    public Result<UpdateRegisterTerminalTypeVo>  updateRegisterTerminalType(@RequestBody UpdateRegisterTerminalTypeDto updateRegisterTerminalTypeDto) {
        UpdateRegisterTerminalTypeVo vo = printService.updateRegisterTerminalType(updateRegisterTerminalTypeDto);
        if (ObjectUtil.isNotEmpty(vo)) {
            return Result.success(Constant.STRING_GET_SUCCESS,vo);
        }
        return Result.error("获取名单异常");
    }
    /**
     * 获取大综合token
     * @author liyafeng
     * @date 2023/3/17
      * @param
     * @return {@link Result< String>}
     */
    @GetMapping("/getDzhToken")
    public Result<String>  getDzhToken() {
        String token = printService.getDzhToken();
        if (StringUtils.isNotBlank(token)) {
            return Result.success(Constant.STRING_GET_SUCCESS,token);
        }
        return Result.error("获取token失败");
    }
}
